package com.cowmooed.controller;

import com.cowmooed.dto.ApiResponseDTO;
import com.cowmooed.dto.SmartFormRecommendationDTO;
import com.cowmooed.dto.SmartFormRequestDTO;
import com.cowmooed.entity.Result;
import com.cowmooed.service.impl.SmartFormService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/smart-form")
@RequiredArgsConstructor
public class SmartFormController {
    private final SmartFormService smartFormService;

    /**
     * 获取智能表单推荐
     */
    @PostMapping("/recommend")
    public Result getRecommendation(
            @RequestBody SmartFormRequestDTO request) {
        try {

            SmartFormRecommendationDTO recommendation = smartFormService.getSmartRecommendation(request);

            return Result.success(ApiResponseDTO.success(recommendation));

        } catch (Exception e) {
            return Result.error("智能推荐服务暂时不可用，请稍后重试");
        }
    }

    /**
     * 健康检查接口
     */
    @GetMapping("/ping")
    public ResponseEntity<ApiResponseDTO<String>> ping() {
        return ResponseEntity.ok(ApiResponseDTO.success("pong"));
    }
}
